package com.hosh.collectvideo

import android.Manifest
import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import com.hosh.video.recorder.VideoRecorder
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {
    private val videoRecorder = VideoRecorder()

    private val PERMISSIONS_STORAGE = arrayOf(
        Manifest.permission.CAMERA,
        Manifest.permission.WRITE_EXTERNAL_STORAGE
    )

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        ActivityCompat.requestPermissions(this,PERMISSIONS_STORAGE, 2)

        videoRecorder.attachCameraView(cameraView)
        btnSwitch.setOnClickListener { v: View? -> cameraView.switchCamera() }
    }
}